home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
C and C++
/
Libraries
/
MacTCP class library
/
MacTCP class headers
/
CDNR.h
next >
Wrap
Text File
|
1992-10-26
|
4KB
|
131 lines
/*
CDNR.h
Superclass: CMacTCPDriver
Dynamic name resolution implementation.
Copyright © NCSA, University of Illinois; June 2, 1992
Igor Livshits
This code may be used, modified, and distributed free of charge and obligation.
*/
#define _H_CDNR // Include this file only once
#include "CMacTCPDriver.h" // Superclass definitions
#include "CIsleResFile.h"
#define kAlternateAddresses 4
#define kControlPanel 'cdev' // File type for control panels
#define kMacTCP 'mtcp' // File creator for the MacTCP control panel
#define kNameResolver 'dnrp' // Resource type of the name resolver
#define kNameResolverID 1 // Resource ID of the name resolver calls
#define kNotFound -1 // Our search was unsuccessful
#define kBasicVersion 1 // A safe assumption
#define kDefault 0 // Default specification
#define kSystem603 0x0603 // System version 6.0.3 (required for MacTCP)
#define kOpen 1L // Procedure assingments
#define kClose 2L
#define kStringToAddress 3L
#define kAddressToString 4L
#define kEnumerateCache 5L
#define kAddressToName 6L
#define kDNRError 2367 // DNR specific errors
#define kNoResolver 1 // Could not access the resolver
typedef enum AddressClasses // Address classes
{
kAddress= 1, // The value is an address
kNameServer, // The value is a name
kCanonicalName= 5, // The vlaue is an alias for the canonical name
kLastClass = 65535 // Upper bound
};
typedef struct hostInfo // Types used by MacTCP (from the MacTCP Documentation Kit)
{
long returnCode; // Are the result fields valid?
char name[255]; // The official name
ip_addr address[kAlternateAddresses]; // List of addresses for the name
}hostInfoRec, *hostInfoPtr;
typedef struct cacheEntryRecord // The cache contents
{
char* name; // The name, of course
unsigned short type; // The type of the entry
enum AddressClasses entryClass; // The class of the entry
unsigned long timeLeft; // The time that the entry has to live in the cache relative to current time
union
{
char* name;
ip_addr address;
} rData; // Specified by the type field
};
/*===---------------===*/
class CDNR : public CMacTCPDriver
Begin
public:
CIsleResFile* fileMacTCP; // The TCP driver
Handle codeHandle; // A handle to the code resource of dnr routines
OSErrProcPtr resolver; // A pointer to the code resource of dnr routines
void IDNR // Initialize the name resolver
( char* fileName // Name of the hosts file (may be null for a default)
);
void Dispose // We are done with the name resolver
( void // No arguments
);
OSErr StringToAddress // Convert from a string to an address
( char* hostName, // Host's name
struct hostInfo* result, // The information record for the host
ProcPtr ResultProc, // Pointer to a procedure to handle results
char* done // Set when non-cache call completes
);
void AddressToString // Convert from an address to a string
( ip_addr address, // The numerical address
char* addressStr // The address as a string
);
void EnumerateCache // Enumerate the entries in the cache
( ProcPtr EnumResultProc, // Pointer to a procedure to handle results
char* done // Set when non-cache call completes
);
OSErr AddressToName // Acquire a canonical name from an address
( ip_addr address, // The numerical address
struct hostInfo* result, // The information record for the host
ProcPtr ResultProc, // Pointer to a procedure to handle results
char* done // Set when non-cache call completes
);
End;
/*===---------------===*/
/*=====================*/
/*===---------------===*/
pascal void EnumResultProc // Called with a pointer to a cache entry
( struct cacheEntryRecord* cacheEntryRecordPtr, // The entry
char* done // Set to true when call completes
);
pascal void ResultProc // Called with an appropriate return code and information
( struct hostInfo* hostInfoPtr, // Pointer to host information
char* done // Set to true when call completes
);
/*===---------------===*/
/*=====================*/
extern tSystem gSystem; // System information